home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # check for users with specified amount of disk space used
- #
- MINUID=500 # where your uids start
- # (lowest "regular user")
- MAXBYTE=4096 # max number of 1024 byte blocks for trigger
- # (1024 * (Megabytes) = MAXSIZE)
- #
- PASSWD="cat /etc/passwd"
-
- HOST=`hostname`
- TMP=/tmp/duck.$$
- rm -f $TMP
-
- DFCOMMAND=/bin/df
-
- touch $TMP
- for i in `$PASSWD | awk -F: '{if ($3 > '$MINUID') print $6}'`
- do
- cd $i
- x=`$DFCOMMAND . | grep "^/"`
- if [ "$x" != "" ]; then # if local to this host
- size=`du -s . | awk '{print $1}'`
- if [ $size -gt $MAXBYTE ]; then
- echo "$i ($size)" >>$TMP
- fi
- fi
- done
-
- n=`wc -l $TMP | awk '{print $1}'`
- if [ $n -gt 0 ]; then
- echo " "
- echo "User directories on $HOST larger than $MAXBYTE 1024-byte blocks:"
- echo " "
- sed 's/^/ /' $TMP
- echo " "
- fi
- /bin/cp $TMP /tmp/user.chk
- rm -f $TMP
-
-